package com.gene.service.impl;

import com.gene.mapper.UserRebateMapper;
import com.gene.pojo.UserRebate;
import com.gene.pojo.UserRebateExample;
import com.gene.service.IUserRebateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRebateServiceImpl implements IUserRebateService {
    @Autowired
    private UserRebateMapper userRebateMapper;

    @Override
    public List<UserRebate> query(UserRebate userRebate) {
        UserRebateExample example=new UserRebateExample();
        UserRebateExample.Criteria criteria = example.createCriteria();
        criteria.andUserIdEqualTo(userRebate.getUserId());
        List<UserRebate> list=userRebateMapper.selectByExample(example);
        return list;
    }

    @Override
    public boolean add(UserRebate userRebate) {
        int a=userRebateMapper.insert(userRebate);
        if(a ==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean edit(UserRebate userRebate) {
        int a=userRebateMapper.updateByPrimaryKeySelective(userRebate);
        if(a ==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(UserRebate userRebate) {
        int a=userRebateMapper.deleteByPrimaryKey(userRebate.getUserRebateId());
        if(a ==1){
            return true;
        }
        return false;
    }

    public Integer sum(UserRebate userRebate){
        return userRebateMapper.sum(userRebate);
    }
}
